<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>签到</title>
    <link rel="stylesheet" href="/Public/libs/layer/need/layer.css">

    <script src="/Public/libs/jquery-1.9.1.min.js"></script>
    <script src="/Public/libs/jquery.getParame.js"></script>
    <script src="/Public/libs/store.legacy.min.js"></script>
    <script src="/Public/libs/vconsole.min.js"></script>
    <script src="/Public/libs/layer/layer.js"></script>

</head>

<body>
    签到中...
</body>
<script>
    $(function () {
        // var vConsole = new VConsole();
        var code = $.getUrlParam('code');
        var state = $.getUrlParam('state');
        // 登录操作
        if (code && state) {
            $.ajax({
                type: 'POST',
                url: '/index.php/Index/register',
                data: {
                    code: code,
                    state: state
                },
                success: function (data) {
                    if (data['return_code'] == 1) {
                        store.set('cj__openid', data['return_body']['openid']);
                        window.location.replace('/index.php/Index/index');
                    } else if (data['return_code'] == 2) {
                        
                        layer.closeAll();
                        layer.open({
                            content: '请先关注公众号',
                            btn: '去关注',
                            shadeClose: false,
                            yes: function () {
                                window.location.replace(
                                    'http://mp.weixin.qq.com/s/bLRXqlqAQ-ptyK8etQ4JGw');

                            }
                        })
                    } else {
                        //删除所有layer
                        layer.closeAll();

                        //信息框
                        layer.open({
                            content: data['return_msg'],
                            btn: '关闭'
                        });
                    }
                },
                error: function (err) {
                    //删除所有layer层
                    layer.closeAll();
                    //信息框
                    layer.open({
                        content: '服务器出了点问题',
                        btn: '关闭'
                    });
                }
            })
        } else {
            alert('参数错误');
        }
    });
</script>

</html>